/**
 * 
 */
package hihocoder;

import java.util.Scanner;

/**
 * @author zhongfang
 *
 */
public class ArrayPartition {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int[] A=new int[N];
		int sum=0;
		for (int i = 0; i < A.length; i++) {
			A[i]=scanner.nextInt();
			sum+=A[i];
		}
		
		int x=sum/3;
		int start=0;
		if(sum%3==0){//每一部分取值只可能是x
			int res=getIndex(start,A,x);
			if(res==-1){
				System.out.println(0);
				return;
			}else {
				start=res+1;
			}
		}
	}

	/**
	 * 获取指定和为x的起点为start的终点位置
	 * @param start
	 * @param a
	 * @param x
	 * @return
	 */
	private static int getIndex(int start, int[] a, int x) {
		int i=start;
		int sum=0;
		while (sum<x) {
			sum+=a[i];
			i++;
		}
		if(sum!=x){
			return -1;
		}else {
			return i-1;
		}
	}

}
